further cleansing - removed most uses of unsigned ints, removed list reversers

Sat, 05 Oct 2013 15:18:47 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sat, 05 Oct 2013 15:18:47 +0300
changeset 498
791c831c8020
parent 497
c51941e590b6
child 499
ebd30d9eb667

further cleansing - removed most uses of unsigned ints, removed list reversers

src/addObjectDialog.cpp file | annotate | diff | comparison | revisions
src/colorSelectDialog.cpp file | annotate | diff | comparison | revisions
src/common.h file | annotate | diff | comparison | revisions
src/configDialog.cpp file | annotate | diff | comparison | revisions
src/configDialog.h file | annotate | diff | comparison | revisions
src/dialogs.cpp file | annotate | diff | comparison | revisions
src/dialogs.h file | annotate | diff | comparison | revisions
src/file.cpp file | annotate | diff | comparison | revisions
src/file.h file | annotate | diff | comparison | revisions
src/gldraw.cpp file | annotate | diff | comparison | revisions
src/gldraw.h file | annotate | diff | comparison | revisions
src/gui.cpp file | annotate | diff | comparison | revisions
src/gui.h file | annotate | diff | comparison | revisions
src/gui_actions.cpp file | annotate | diff | comparison | revisions
src/gui_editactions.cpp file | annotate | diff | comparison | revisions
src/history.cpp file | annotate | diff | comparison | revisions
src/history.h file | annotate | diff | comparison | revisions
src/ldconfig.cpp file | annotate | diff | comparison | revisions
src/ldconfig.h file | annotate | diff | comparison | revisions
src/ldtypes.cpp file | annotate | diff | comparison | revisions
src/main.cpp file | annotate | diff | comparison | revisions
src/messagelog.cpp file | annotate | diff | comparison | revisions
src/misc.cpp file | annotate | diff | comparison | revisions
src/misc.h file | annotate | diff | comparison | revisions
src/primitives.cpp file | annotate | diff | comparison | revisions
src/primitives.h file | annotate | diff | comparison | revisions
src/types.cpp file | annotate | diff | comparison | revisions
src/types.h file | annotate | diff | comparison | revisions
src/widgets.cpp file | annotate | diff | comparison | revisions
src/widgets.h file | annotate | diff | comparison | revisions
--- a/src/addObjectDialog.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/addObjectDialog.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -404,7 +404,7 @@
 		obj->setColor (dlg.colnum);
 
 	if (newObject)
-	{	ulong idx = g_win->getInsertionPoint();
+	{	int idx = g_win->getInsertionPoint();
 		LDFile::current()->insertObj (idx, obj);
 	}
 
--- a/src/colorSelectDialog.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/colorSelectDialog.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -167,9 +167,9 @@
 void ColorSelector::mousePressEvent (QMouseEvent* event)
 {	QPointF scenepos = ui->viewport->mapToScene (event->pos());
 
-	ulong x = ( (ulong) scenepos.x() - (g_squareSize / 2)) / g_squareSize;
-	ulong y = ( (ulong) scenepos.y() - (g_squareSize / 2)) / g_squareSize;
-	ulong idx = (y * g_numColumns) + x;
+	int x = (scenepos.x() - (g_squareSize / 2)) / g_squareSize;
+	int y = (scenepos.y() - (g_squareSize / 2)) / g_squareSize;
+	int idx = (y * g_numColumns) + x;
 
 	LDColor* col = ::getColor (idx);
 
--- a/src/common.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/common.h	Sat Oct 05 15:18:47 2013 +0300
@@ -148,7 +148,7 @@
 #undef assert
 #endif // assert
 
-void assertionFailure (const char* file, const ulong line, const char* funcname, const char* expr);
+void assertionFailure (const char* file, int line, const char* funcname, const char* expr);
 #define assert(N) ((N) ? (void) 0 : assertionFailure (__FILE__, __LINE__, FUNCNAME, #N))
 
 // Version string identifier
--- a/src/configDialog.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/configDialog.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -105,7 +105,7 @@
 	ui->implicitFiles->setChecked (gui_implicitfiles);
 	ui->m_logostuds->setChecked (gl_logostuds);
 
-	ulong i = 0;
+	int i = 0;
 #define act(N) addShortcut (key_##N, ACTION(N), i);
 #include "actions.h"
 
@@ -153,7 +153,7 @@
 // =============================================================================
 // Adds a shortcut entry to the list of shortcuts.
 // -----------------------------------------------------------------------------
-void ConfigDialog::addShortcut (KeySequenceConfig& cfg, QAction* act, ulong& i)
+void ConfigDialog::addShortcut (KeySequenceConfig& cfg, QAction* act, int& i)
 {	ShortcutListItem* item = new ShortcutListItem;
 	item->setIcon (act->icon());
 	item->setKeyConfig (&cfg);
@@ -210,7 +210,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-static const struct extProgInfo
+static const struct LDExtProgInfo
 {	const str name, iconname;
 	StringConfig* const path;
 	mutable QLineEdit* input;
@@ -219,7 +219,7 @@
 	BoolConfig* const wine;
 	mutable QCheckBox* wineBox;
 #endif // _WIN32
-} g_extProgInfo[] =
+} g_LDExtProgInfo[] =
 {
 #ifndef _WIN32
 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null, &prog_##LOWNAME##_wine, null },
@@ -240,9 +240,9 @@
 // -----------------------------------------------------------------------------
 void ConfigDialog::initExtProgs()
 {	QGridLayout* pathsLayout = new QGridLayout;
-	ulong row = 0;
+	int row = 0;
 
-for (const extProgInfo & info : g_extProgInfo)
+	for (const LDExtProgInfo& info : g_LDExtProgInfo)
 	{	QLabel* icon = new QLabel,
 		*progLabel = new QLabel (info.name);
 		QLineEdit* input = new QLineEdit;
@@ -307,7 +307,7 @@
 #include "actions.h"
 
 	// Ext program settings
-for (const extProgInfo & info : g_extProgInfo)
+	for (const LDExtProgInfo& info : g_LDExtProgInfo)
 	{	*info.path = info.input->text();
 
 #ifndef _WIN32
@@ -396,7 +396,7 @@
 		if (!item)
 			return;
 
-		ulong i = getItemRow (item, quickColorItems);
+		int i = getItemRow (item, quickColorItems);
 		entry = &quickColors[i];
 
 		if (entry->isSeparator() == true)
@@ -415,12 +415,7 @@
 	{	LDQuickColor entry (getColor (val), null);
 
 		item = getSelectedQuickColor();
-		ulong idx;
-
-		if (item)
-			idx = getItemRow (item, quickColorItems) + 1;
-		else
-			idx = quickColorItems.size();
+		int idx = (item) ? getItemRow (item, quickColorItems) + 1 : quickColorItems.size();
 
 		quickColors.insert (idx, entry);
 		entry = quickColors[idx];
@@ -454,7 +449,7 @@
 	int idx = getItemRow (item, quickColorItems);
 	int dest = up ? (idx - 1) : (idx + 1);
 
-	if (dest < 0 || (ulong) dest >= quickColorItems.size())
+	if (dest < 0 || dest >= quickColorItems.size())
 		return; // destination out of bounds
 
 	LDQuickColor tmp = quickColors[dest];
@@ -597,9 +592,9 @@
 // Set the path of an external program
 // -----------------------------------------------------------------------------
 void ConfigDialog::slot_setExtProgPath()
-{	const extProgInfo* info = null;
+{	const LDExtProgInfo* info = null;
 
-for (const extProgInfo & it : g_extProgInfo)
+for (const LDExtProgInfo & it : g_LDExtProgInfo)
 	{	if (it.setPathButton == sender())
 		{	info = &it;
 			break;
--- a/src/configDialog.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/configDialog.h	Sat Oct 05 15:18:47 2013 +0300
@@ -65,7 +65,7 @@
 		List<QListWidgetItem*> quickColorItems;
 
 		void applySettings();
-		void addShortcut (KeySequenceConfig& cfg, QAction* act, ulong& i);
+		void addShortcut (KeySequenceConfig& cfg, QAction* act, int& i);
 		void setButtonBackground (QPushButton* button, str value);
 		void pickColor (StringConfig& cfg, QPushButton* button);
 		void updateQuickColorList (LDQuickColor* sel = null);
--- a/src/dialogs.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/dialogs.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -109,11 +109,11 @@
 {	return ui->filename->text();
 }
 
-ushort OverlayDialog::ofsx() const
+int OverlayDialog::ofsx() const
 {	return ui->originX->value();
 }
 
-ushort OverlayDialog::ofsy() const
+int OverlayDialog::ofsy() const
 {	return ui->originY->value();
 }
 
@@ -249,13 +249,13 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-READ_ACCESSOR (ulong, OpenProgressDialog::numLines)
+READ_ACCESSOR (int, OpenProgressDialog::numLines)
 {	return m_numLines;
 }
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-SET_ACCESSOR (ulong, OpenProgressDialog::setNumLines)
+SET_ACCESSOR (int, OpenProgressDialog::setNumLines)
 {	m_numLines = val;
 	ui->progressBar->setRange (0, numLines());
 	updateValues();
--- a/src/dialogs.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/dialogs.h	Sat Oct 05 15:18:47 2013 +0300
@@ -48,8 +48,8 @@
 		virtual ~OverlayDialog();
 
 		str         fpath() const;
-		ushort      ofsx() const;
-		ushort      ofsy() const;
+		int         ofsx() const;
+		int         ofsy() const;
 		double      lwidth() const;
 		double      lheight() const;
 		int         camera() const;
@@ -92,8 +92,8 @@
 // =============================================================================
 class OpenProgressDialog : public QDialog
 {	Q_OBJECT
-	READ_PROPERTY (ulong, progress, setProgress)
-	DECLARE_PROPERTY (ulong, numLines, setNumLines)
+	READ_PROPERTY (int, progress, setProgress)
+	DECLARE_PROPERTY (int, numLines, setNumLines)
 
 	public:
 		explicit OpenProgressDialog (QWidget* parent = null, Qt::WindowFlags f = 0);
--- a/src/file.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/file.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -133,7 +133,7 @@
 		delete obj;
 
 	// Remove this file from the list of files
-	for (ulong i = 0; i < g_loadedFiles.size(); ++i)
+	for (int i = 0; i < g_loadedFiles.size(); ++i)
 	{	if (g_loadedFiles[i] == this)
 		{	g_loadedFiles.erase (i);
 			break;
@@ -361,7 +361,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-List<LDObject*> loadFileContents (File* f, ulong* numWarnings, bool* ok)
+List<LDObject*> loadFileContents (File* f, int* numWarnings, bool* ok)
 {	List<str> lines;
 	List<LDObject*> objs;
 
@@ -420,14 +420,14 @@
 	LDFile* load = new LDFile;
 	load->setName (path);
 
-	ulong numWarnings;
+	int numWarnings;
 	bool ok;
 	List<LDObject*> objs = loadFileContents (f, &numWarnings, &ok);
 
 	if (!ok)
 		return null;
 
-for (LDObject * obj : objs)
+	for (LDObject* obj : objs)
 		load->addObject (obj);
 
 	delete f;
@@ -641,13 +641,13 @@
 		return new LDError (line, "Bad amount of tokens");
 
 #define CHECK_TOKEN_NUMBERS(MIN, MAX) \
-	for (ushort i = MIN; i <= MAX; ++i) \
+	for (int i = MIN; i <= MAX; ++i) \
 		if (!isNumber (tokens[i])) \
 			return new LDError (line, fmt ("Token #%1 was `%2`, expected a number", (i + 1), tokens[i]));
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-static vertex parseVertex (QStringList& s, const ushort n)
+static vertex parseVertex (QStringList& s, const int n)
 {	vertex v;
 
 for (const Axis ax : g_Axes)
@@ -875,7 +875,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-ulong LDFile::addObject (LDObject* obj)
+int LDFile::addObject (LDObject* obj)
 {	m_history.add (new AddHistory (objects().size(), obj));
 	m_objects << obj;
 
@@ -896,7 +896,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void LDFile::insertObj (const ulong pos, LDObject* obj)
+void LDFile::insertObj (int pos, LDObject* obj)
 {	m_history.add (new AddHistory (pos, obj));
 	m_objects.insert (pos, obj);
 	obj->setFile (this);
@@ -905,7 +905,7 @@
 // =============================================================================
 // -----------------------------------------------------------------------------
 void LDFile::forgetObject (LDObject* obj)
-{	ulong idx = obj->getIndex();
+{	int idx = obj->getIndex();
 	m_history.add (new DelHistory (idx, obj));
 	m_objects.erase (idx);
 	obj->setFile (null);
@@ -923,7 +923,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void LDFile::setObject (ulong idx, LDObject* obj)
+void LDFile::setObject (int idx, LDObject* obj)
 {	assert (idx < numObjs());
 
 	// Mark this change to history
@@ -987,7 +987,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-LDObject* LDFile::object (ulong pos) const
+LDObject* LDFile::object (int pos) const
 {	if (m_objects.size() <= pos)
 		return null;
 
@@ -996,13 +996,13 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-LDObject* LDFile::obj (ulong pos) const
+LDObject* LDFile::obj (int pos) const
 {	return object (pos);
 }
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-ulong LDFile::numObjs() const
+int LDFile::numObjs() const
 {	return objects().size();
 }
 
--- a/src/file.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/file.h	Sat Oct 05 15:18:47 2013 +0300
@@ -63,19 +63,19 @@
 		LDFile();
 		~LDFile();
 
-		ulong addObject (LDObject* obj);                 // Adds an object to this file at the end of the file.
+		int addObject (LDObject* obj);                 // Adds an object to this file at the end of the file.
 		void addObjects (const List<LDObject*> objs);
 		void forgetObject (LDObject* obj);               // Deletes the given object from the object chain.
 		str getShortName();
 		bool hasUnsavedChanges() const;                  // Does this file have unsaved changes?
 		List<LDObject*> inlineContents (LDSubfile::InlineFlags flags);
-		void insertObj (const ulong pos, LDObject* obj);
-		ulong numObjs() const;
-		LDObject* object (ulong pos) const;
-		LDObject* obj (ulong pos) const;
+		void insertObj (int pos, LDObject* obj);
+		int numObjs() const;
+		LDObject* object (int pos) const;
+		LDObject* obj (int pos) const;
 		bool save (str path = "");                       // Saves this file to disk.
 		bool safeToClose();                              // Perform safety checks. Do this before closing any files!
-		void setObject (ulong idx, LDObject* obj);
+		void setObject (int idx, LDObject* obj);
 
 		inline LDFile& operator<< (LDObject* obj)
 		{	addObject (obj);
@@ -147,7 +147,7 @@
 // Is it safe to close all files?
 bool safeToCloseAll();
 
-List<LDObject*> loadFileContents (File* f, ulong* numWarnings, bool* ok = null);
+List<LDObject*> loadFileContents (File* f, int* numWarnings, bool* ok = null);
 
 extern List<LDFile*> g_loadedFiles;
 
@@ -170,10 +170,10 @@
 {		Q_OBJECT
 		READ_PROPERTY (List<LDObject*>, objs, setObjects)
 		READ_PROPERTY (bool, done, setDone)
-		READ_PROPERTY (ulong, progress, setProgress)
+		READ_PROPERTY (int, progress, setProgress)
 		READ_PROPERTY (bool, aborted, setAborted)
 		PROPERTY (List<str>, lines, setLines)
-		PROPERTY (ulong*, warningsPointer, setWarningsPointer)
+		PROPERTY (int*, warningsPointer, setWarningsPointer)
 		PROPERTY (bool, concurrent, setConcurrent)
 
 	public slots:
--- a/src/gldraw.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/gldraw.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -1105,7 +1105,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void GLRenderer::pick (uint mouseX, uint mouseY)
+void GLRenderer::pick (int mouseX, int mouseY)
 {	GLint viewport[4];
 	makeCurrent();
 
@@ -1194,7 +1194,7 @@
 		if (!m_rangepick && m_addpick)
 		{	bool removed = false;
 
-			for (ulong i = 0; i < g_win->sel().size(); ++i)
+			for (int i = 0; i < g_win->sel().size(); ++i)
 			{	if (g_win->sel() [i] == obj)
 				{	g_win->sel().erase (i);
 					obj->setSelected (false);
@@ -1341,7 +1341,7 @@
 
 						obj->setColor (maincolor);
 
-						for (ushort i = 0; i < obj->vertices(); ++i)
+						for (int i = 0; i < obj->vertices(); ++i)
 							obj->setVertex (i, verts[i]);
 
 						break;
@@ -1459,7 +1459,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-uchar* GLRenderer::screencap (ushort& w, ushort& h)
+uchar* GLRenderer::screencap (int& w, int& h)
 {	w = m_width;
 	h = m_height;
 	uchar* cap = new uchar[4 * w * h];
@@ -1650,12 +1650,12 @@
 		bool filled = false;
 
 		// Check the top and bottom rows
-		for (ushort i = 0; i < w && !filled; ++i)
+		for (int i = 0; i < w && !filled; ++i)
 			if (imgdata[i] != white || imgdata[ ( (h - 1) * w) + i] != white)
 				filled = true;
 
 		// Left and right edges
-		for (ushort i = 0; i < h && !filled; ++i)
+		for (int i = 0; i < h && !filled; ++i)
 			if (imgdata[i * w] != white || imgdata[ (i * w) + (w - 1)] != white)
 				filled = true;
 
@@ -1813,7 +1813,7 @@
 			// the last one found. Otherwise, place it before the first schemantic
 			// object and put an empty object after it (though don't do this if
 			// there was no schemantic elements at all)
-			ulong i, lastOverlay = -1u;
+			int i, lastOverlay = -1;
 			bool found = false;
 
 			for (i = 0; i < file()->numObjs(); ++i)
@@ -1828,7 +1828,7 @@
 					lastOverlay = i;
 			}
 
-			if (lastOverlay != -1u)
+			if (lastOverlay != -1)
 				file()->insertObj (lastOverlay + 1, ovlobj);
 			else
 			{	file()->insertObj (i, ovlobj);
--- a/src/gldraw.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/gldraw.h	Sat Oct 05 15:18:47 2013 +0300
@@ -41,7 +41,7 @@
 // Meta for overlays
 struct LDGLOverlay
 {	vertex v0, v1;
-	ushort ox, oy;
+	int ox, oy;
 	double lw, lh;
 	str fname;
 	QImage* img;
@@ -96,7 +96,7 @@
 		void           overlaysFromObjects();
 		void           refresh();
 		void           resetAngles();
-		uchar*         screencap (ushort& w, ushort& h);
+		uchar*         screencap (int& w, int& h);
 		void           setBackground();
 		void           setCamera (const Camera cam);
 		void           setDepthValue (double depth);
@@ -135,7 +135,6 @@
 		QTimer*               m_toolTipTimer;
 		Qt::MouseButtons      m_lastButtons;
 		Qt::KeyboardModifiers m_keymods;
-		ulong                 m_totalmove;
 		vertex                m_hoverpos;
 		double                m_virtWidth,
 		                      m_virtHeight,
@@ -158,7 +157,8 @@
 		                      m_toolTipCamera;
 		GLuint                m_axeslist;
 		int                   m_width,
-		                      m_height;
+		                      m_height,
+							  m_totalmove;
 		List<vertex>          m_drawedVerts;
 		bool                  m_rectdraw;
 		vertex                m_rectverts[4];
@@ -178,7 +178,7 @@
 		QPoint         coordconv3_2 (const vertex& pos3d) const;               // Convert a 3D point to a 2D point
 		LDOverlay*     findOverlayObject (Camera cam);
 		void           updateRectVerts();
-		void           pick (uint mouseX, uint mouseY);                        // Perform object selection
+		void           pick (int mouseX, int mouseY);                          // Perform object selection
 		void           setObjectColor (LDObject* obj, const ListType list);    // Set the color to an object list
 		QColor         getTextPen() const;                                     // Determine which color to draw text with
 		void           getRelativeAxes (Axis& relX, Axis& relY) const;
--- a/src/gui.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/gui.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -456,7 +456,7 @@
 
 	short newColor = col->index;
 
-for (LDObject * obj : m_sel)
+	for (LDObject * obj : m_sel)
 	{	if (obj->isColored() == false)
 			continue; // uncolored object
 
@@ -470,7 +470,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-ulong ForgeWindow::getInsertionPoint()
+int ForgeWindow::getInsertionPoint()
 {	if (m_sel.size() > 0)
 	{	// If we have a selection, put the item after it.
 		return (m_sel[m_sel.size() - 1]->getIndex()) + 1;
@@ -665,7 +665,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void ForgeWindow::primitiveLoaderStart (ulong max)
+void ForgeWindow::primitiveLoaderStart (int max)
 {	m_primLoaderWidget->show();
 	m_primLoaderBar->setRange (0, max);
 	m_primLoaderBar->setValue (0);
@@ -674,7 +674,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void ForgeWindow::primitiveLoaderUpdate (ulong prog)
+void ForgeWindow::primitiveLoaderUpdate (int prog)
 {	m_primLoaderBar->setValue (prog);
 }
 
@@ -765,7 +765,7 @@
 }
 
 // =============================================================================
-QIcon makeColorIcon (LDColor* colinfo, const ushort size)
+QIcon makeColorIcon (LDColor* colinfo, const int size)
 {	// Create an image object and link a painter to it.
 	QImage img (size, size, QImage::Format_ARGB32);
 	QPainter paint (&img);
@@ -787,9 +787,9 @@
 
 // =============================================================================
 void makeColorSelector (QComboBox* box)
-{	std::map<short, ulong> counts;
+{	std::map<int, int> counts;
 
-for (LDObject * obj : LDFile::current()->objects())
+	for (LDObject * obj : LDFile::current()->objects())
 	{	if (!obj->isColored())
 			continue;
 
@@ -800,9 +800,9 @@
 	}
 
 	box->clear();
-	ulong row = 0;
+	int row = 0;
 
-for (const auto & pair : counts)
+	for (const auto & pair : counts)
 	{	LDColor* col = getColor (pair.first);
 		assert (col != null);
 
@@ -924,7 +924,7 @@
 	buildObjList();
 }
 
-QImage imageFromScreencap (uchar* data, ushort w, ushort h)
+QImage imageFromScreencap (uchar* data, int w, int h)
 {	// GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well.
 	return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored();
 }
--- a/src/gui.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/gui.h	Sat Oct 05 15:18:47 2013 +0300
@@ -97,7 +97,7 @@
 		void updateTitle();
 		void fullRefresh();
 		void refresh();
-		ulong getInsertionPoint();
+		int getInsertionPoint();
 		void updateToolBars();
 		void updateRecentFilesMenu();
 		void updateSelection();
@@ -138,8 +138,8 @@
 #include "actions.h"
 
 	public slots:
-		void primitiveLoaderStart (ulong max);
-		void primitiveLoaderUpdate (ulong prog);
+		void primitiveLoaderStart (int max);
+		void primitiveLoaderUpdate (int prog);
 		void primitiveLoaderEnd();
 		void clearSelection();
 		void slot_action();
@@ -185,9 +185,9 @@
 bool confirm (str title, str msg); // Generic confirm prompt
 bool confirm (str msg); // Generic confirm prompt
 void critical (str msg); // Generic error prompt
-QIcon makeColorIcon (LDColor* colinfo, const ushort size); // Makes an icon for the given color
+QIcon makeColorIcon (LDColor* colinfo, const int size); // Makes an icon for the given color
 void makeColorSelector (QComboBox* box); // Fills the given combo-box with color information
-QImage imageFromScreencap (uchar* data, ushort w, ushort h);
+QImage imageFromScreencap (uchar* data, int w, int h);
 
 // =============================================================================
 // -----------------------------------------------------------------------------
--- a/src/gui_actions.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/gui_actions.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -242,7 +242,6 @@
 // -----------------------------------------------------------------------------
 DEFINE_ACTION (Help, KEY (F1))
 {
-
 }
 
 // =============================================================================
@@ -351,7 +350,7 @@
 // -----------------------------------------------------------------------------
 DEFINE_ACTION (InsertFrom, 0)
 {	str fname = QFileDialog::getOpenFileName();
-	ulong idx = g_win->getInsertionPoint();
+	int idx = g_win->getInsertionPoint();
 
 	if (!fname.length())
 		return;
@@ -408,7 +407,7 @@
 // =============================================================================
 // -----------------------------------------------------------------------------
 DEFINE_ACTION (InsertRaw, 0)
-{	ulong idx = g_win->getInsertionPoint();
+{	int idx = g_win->getInsertionPoint();
 
 	QDialog* const dlg = new QDialog;
 	QVBoxLayout* const layout = new QVBoxLayout;
@@ -445,7 +444,7 @@
 DEFINE_ACTION (Screenshot, 0)
 {	setlocale (LC_ALL, "C");
 
-	ushort w, h;
+	int w, h;
 	uchar* imgdata = g_win->R()->screencap (w, h);
 	QImage img = imageFromScreencap (imgdata, w, h);
 
@@ -553,7 +552,7 @@
 		return;
 	}
 
-	ushort w, h;
+	int w, h;
 
 	GLRenderer* rend = new GLRenderer;
 	rend->resize (64, 64);
--- a/src/gui_editactions.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/gui_editactions.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -81,7 +81,7 @@
 // -----------------------------------------------------------------------------
 DEFINE_ACTION (Paste, CTRL (V))
 {	const str clipboardText = qApp->clipboard()->text();
-	ulong idx = g_win->getInsertionPoint();
+	int idx = g_win->getInsertionPoint();
 	g_win->sel().clear();
 	int num = 0;
 
@@ -310,9 +310,9 @@
 	{	if (obj->vertices() < 2)
 			continue;
 
-		ulong idx = obj->getIndex();
+		int idx = obj->getIndex();
 
-		for (short i = 0; i < obj->vertices(); ++i)
+		for (int i = 0; i < obj->vertices(); ++i)
 		{	LDVertex* vert = new LDVertex;
 			vert->pos = obj->getVertex (i);
 			vert->setColor (obj->color());
--- a/src/history.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/history.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -41,8 +41,8 @@
 	g_fullRefresh = false;
 
 	// Iterate the list in reverse and undo all actions
-	for (const AbstractHistoryEntry* change : c_rev<AbstractHistoryEntry*> (set))
-		change->undo();
+	for (auto it = set.end() - 1; it != set.begin(); --it)
+		(*it)->undo();
 
 	setPos (pos() - 1);
 
--- a/src/history.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/history.h	Sat Oct 05 15:18:47 2013 +0300
@@ -100,34 +100,34 @@
 			Other,	// was deleted witout specific reason
 		};
 
-		PROPERTY (ulong, index, setIndex)
+		PROPERTY (int, index, setIndex)
 		PROPERTY (str, code, setCode)
 		PROPERTY (DelHistory::Type, type, setType)
 
 	public:
 		IMPLEMENT_HISTORY_TYPE (Del)
 
-		DelHistory (ulong idx, LDObject* obj, Type type = Other) :
-			m_index (idx),
-			m_code (obj->raw()),
-			m_type (type) {}
+		DelHistory (int idx, LDObject* obj, Type type = Other) :
+				m_index (idx),
+				m_code (obj->raw()),
+				m_type (type) {}
 };
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 class EditHistory : public AbstractHistoryEntry
-{	PROPERTY (ulong, index, setIndex)
+{	PROPERTY (int, index, setIndex)
 	PROPERTY (str, oldCode, setOldCode)
 	PROPERTY (str, newCode, setNewCode)
 
 	public:
 		IMPLEMENT_HISTORY_TYPE (Edit)
 
-		EditHistory (ulong idx, str oldCode, str newCode) :
-			m_index (idx),
-			m_oldCode (oldCode),
-			m_newCode (newCode) {}
+		EditHistory (int idx, str oldCode, str newCode) :
+				m_index (idx),
+				m_oldCode (oldCode),
+				m_newCode (newCode) {}
 };
 
 // =============================================================================
@@ -140,17 +140,17 @@
 			Paste,	// was added through a paste operation
 		};
 
-		PROPERTY (ulong, index, setIndex)
+		PROPERTY (int, index, setIndex)
 		PROPERTY (str, code, setCode)
 		PROPERTY (AddHistory::Type, type, setType)
 
 	public:
 		IMPLEMENT_HISTORY_TYPE (Add)
 
-		AddHistory (ulong idx, LDObject* obj, Type type = Other) :
-			m_index (idx),
-			m_code (obj->raw()),
-			m_type (type) {}
+		AddHistory (int idx, LDObject* obj, Type type = Other) :
+				m_index (idx),
+				m_code (obj->raw()),
+				m_type (type) {}
 };
 
 // =============================================================================
@@ -160,22 +160,22 @@
 {	public:
 		IMPLEMENT_HISTORY_TYPE (Move)
 
-		List<ulong> indices;
+		List<int> indices;
 		vertex dest;
 
-		MoveHistory (List<ulong> indices, vertex dest) :
-			indices (indices),
-			dest (dest) {}
+		MoveHistory (List<int> indices, vertex dest) :
+				indices (indices),
+				dest (dest) {}
 };
 
 class SwapHistory : public AbstractHistoryEntry
 {	public:
 		IMPLEMENT_HISTORY_TYPE (Swap)
-		ulong a, b;
+		int a, b;
 
-		SwapHistory (ulong a, ulong b) :
-			a (a),
-			b (b) {}
+		SwapHistory (int a, int b) :
+				a (a),
+				b (b) {}
 };
 
 #endif // HISTORY_H
--- a/src/ldconfig.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/ldconfig.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -131,7 +131,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-bool LDConfigParser::getToken (str& val, const ushort pos)
+bool LDConfigParser::getToken (str& val, const int pos)
 {	if (pos >= m_tokens.size())
 		return false;
 
@@ -154,7 +154,7 @@
 // =============================================================================
 // -----------------------------------------------------------------------------
 bool LDConfigParser::findToken (short& result, char const* needle, short args)
-{	for (ushort i = 0; i < (m_tokens.size() - args); ++i)
+{	for (int i = 0; i < (m_tokens.size() - args); ++i)
 	{	if (m_tokens[i] == needle)
 		{	result = i;
 			return true;
--- a/src/ldconfig.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/ldconfig.h	Sat Oct 05 15:18:47 2013 +0300
@@ -35,7 +35,7 @@
 		bool atBeginning();
 		bool next (str& val);
 		bool peekNext (str& val);
-		bool getToken (str& val, const ushort pos);
+		bool getToken (str& val, const int pos);
 		bool findToken (short& result, char const* needle, short args);
 		size_t size();
 		void rewind();
--- a/src/ldtypes.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/ldtypes.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -113,7 +113,7 @@
 str LDLine::raw()
 {	str val = fmt ("2 %1", color());
 
-	for (ushort i = 0; i < 2; ++i)
+	for (int i = 0; i < 2; ++i)
 		val += fmt (" %1", getVertex (i));
 
 	return val;
@@ -124,7 +124,7 @@
 str LDTriangle::raw()
 {	str val = fmt ("3 %1", color());
 
-	for (ushort i = 0; i < 3; ++i)
+	for (int i = 0; i < 3; ++i)
 		val += fmt (" %1", getVertex (i));
 
 	return val;
@@ -135,7 +135,7 @@
 str LDQuad::raw()
 {	str val = fmt ("4 %1", color());
 
-	for (ushort i = 0; i < 4; ++i)
+	for (int i = 0; i < 4; ++i)
 		val += fmt (" %1", getVertex (i));
 
 	return val;
@@ -147,7 +147,7 @@
 {	str val = fmt ("5 %1", color());
 
 	// Add the coordinates
-	for (ushort i = 0; i < 4; ++i)
+	for (int i = 0; i < 4; ++i)
 		val += fmt (" %1", getVertex (i));
 
 	return val;
@@ -254,7 +254,7 @@
 // -----------------------------------------------------------------------------
 LDObject::~LDObject()
 {	// Remove this object from the selection array if it is there.
-	for (ulong i = 0; i < g_win->sel().size(); ++i)
+	for (int i = 0; i < g_win->sel().size(); ++i)
 		if (g_win->sel() [i] == this)
 			g_win->sel().erase (i);
 
@@ -262,9 +262,9 @@
 	GL::deleteLists (this);
 
 	// Remove this object from the list of LDObjects
-	ulong pos = g_LDObjects.find (this);
+	int pos;
 
-	if (pos < g_LDObjects.size())
+	if ((pos = g_LDObjects.find (this)) != -1)
 		g_LDObjects.erase (pos);
 }
 
@@ -327,7 +327,7 @@
 	assert (file() != null);
 #endif
 
-	for (ulong i = 0; i < file()->numObjs(); ++i)
+	for (int i = 0; i < file()->numObjs(); ++i)
 		if (file()->obj (i) == this)
 			return i;
 
@@ -395,25 +395,25 @@
 
 	for (long i = 0; i < LDObject::NumTypes; ++i)
 	{	LDObject::Type objType = (LDObject::Type) i;
-		ulong objCount = 0;
+		int count = 0;
 
-	for (LDObject * obj : objs)
+		for (LDObject * obj : objs)
 			if (obj->getType() == objType)
-				objCount++;
+				count++;
 
-		if (objCount == 0)
+		if (count == 0)
 			continue;
 
 		if (!firstDetails)
 			text += ", ";
 
-		str noun = fmt ("%1%2", typeName (objType), plural (objCount));
+		str noun = fmt ("%1%2", typeName (objType), plural (count));
 
 		// Plural of "vertex" is "vertices". Stupid English.
-		if (objType == LDObject::Vertex && objCount != 1)
+		if (objType == LDObject::Vertex && count != 1)
 			noun = "vertices";
 
-		text += fmt ("%1 %2", objCount, noun);
+		text += fmt ("%1 %2", count, noun);
 		firstDetails = false;
 	}
 
@@ -578,7 +578,7 @@
 	// flipped but I don't have a method for checking flatness yet.
 	// Food for thought...
 
-	ulong idx = getIndex();
+	int idx = getIndex();
 
 	if (idx > 0)
 	{	LDBFC* bfc = dynamic_cast<LDBFC*> (prev());
--- a/src/main.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/main.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -139,7 +139,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void assertionFailure (const char* file, const ulong line, const char* funcname, const char* expr)
+void assertionFailure (const char* file, int line, const char* funcname, const char* expr)
 {	str errmsg = fmt ("File: %1\nLine: %2:\nFunction %3:\n\nAssertion `%4' failed",
 					  file, line, funcname, expr);
 
--- a/src/messagelog.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/messagelog.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -23,7 +23,7 @@
 #include "gui.h"
 #include "moc_messagelog.cpp"
 
-static const unsigned int g_maxMessages = 5;
+static const int g_maxMessages = 5;
 static const int g_expiry = 5;
 static const int g_fadeTime = 500; // msecs
 
@@ -93,7 +93,7 @@
 
 	bool changed = false;
 
-	for (uint i = 0; i < m_lines.size(); ++i)
+	for (int i = 0; i < m_lines.size(); ++i)
 	{	bool lineChanged;
 
 		if (!m_lines[i].update (lineChanged))
--- a/src/misc.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/misc.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -26,7 +26,7 @@
 #include "ui_rotpoint.h"
 
 // Prime number table.
-const ushort g_primes[NUM_PRIMES] =
+const int g_primes[NUM_PRIMES] =
 {	2,    3,    5,    7,   11,   13,   17,   19,   23,   29,
 	31,   37,   41,   43,   47,   53,   59,   61,   67,   71,
 	73,   79,   83,   89,   97,  101,  103,  107,  109,  113,
@@ -187,8 +187,8 @@
 	do
 	{	repeat = false;
 
-		for (ushort x = 0; x < NUM_PRIMES; x++)
-		{	const ushort prime = g_primes[NUM_PRIMES - x - 1];
+		for (int x = 0; x < NUM_PRIMES; x++)
+		{	const int prime = g_primes[NUM_PRIMES - x - 1];
 
 			if (numer <= prime || denom <= prime)
 				continue;
--- a/src/misc.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/misc.h	Sat Oct 05 15:18:47 2013 +0300
@@ -29,7 +29,7 @@
 class QAction;
 
 // Prime numbers
-extern const ushort g_primes[NUM_PRIMES];
+extern const int g_primes[NUM_PRIMES];
 
 // Returns whether a given string represents a floating point number.
 bool isNumber (const str& tok);
--- a/src/primitives.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/primitives.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -100,8 +100,8 @@
 	m_prims.clear();
 
 	QDir dir (LDPaths::prims());
-	ulong baselen = dir.absolutePath().length();
-	ulong i = 0;
+	int baselen = dir.absolutePath().length();
+	int i = 0;
 	List<str> fnames;
 
 	assert (dir.exists());
@@ -155,8 +155,8 @@
 	PrimitiveLister* lister = new PrimitiveLister;
 	QThread* listerThread = new QThread;
 	lister->moveToThread (listerThread);
-	connect (lister, SIGNAL (starting (ulong)), g_win, SLOT (primitiveLoaderStart (ulong)));
-	connect (lister, SIGNAL (update (ulong)), g_win, SLOT (primitiveLoaderUpdate (ulong)));
+	connect (lister, SIGNAL (starting (int)), g_win, SLOT (primitiveLoaderStart (int)));
+	connect (lister, SIGNAL (update (int)), g_win, SLOT (primitiveLoaderUpdate (int)));
 	connect (lister, SIGNAL (workDone()), g_win, SLOT (primitiveLoaderEnd()));
 	connect (listerThread, SIGNAL (started()), lister, SLOT (work()));
 	connect (listerThread, SIGNAL (finished()), lister, SLOT (deleteLater()));
--- a/src/primitives.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/primitives.h	Sat Oct 05 15:18:47 2013 +0300
@@ -69,9 +69,9 @@
 		void work();
 
 	signals:
-		void starting (ulong num);
+		void starting (int num);
 		void workDone();
-		void update (ulong i);
+		void update (int i);
 
 	private:
 		List<Primitive> m_prims;
--- a/src/types.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/types.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -103,11 +103,11 @@
 // =============================================================================
 // -----------------------------------------------------------------------------
 double& vertex::operator[] (const Axis ax)
-{	return coord ( (ushort) ax);
+{	return coord ( (int) ax);
 }
 
 const double& vertex::operator[] (const Axis ax) const
-{	return coord ( (ushort) ax);
+{	return coord ( (int) ax);
 }
 
 double& vertex::operator[] (const int ax)
--- a/src/types.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/types.h	Sat Oct 05 15:18:47 2013 +0300
@@ -28,8 +28,6 @@
 
 typedef QChar qchar;
 typedef QString str;
-template<class T> class ConstListReverser;
-template<class T> using c_rev = ConstListReverser<T>;
 class StringConfig;
 class IntConfig;
 class FloatConfig;
@@ -217,7 +215,7 @@
 		{	return m_vect.crend();
 		}
 
-		void erase (ulong pos)
+		void erase (int pos)
 		{	assert (pos < size());
 			m_vect.erase (m_vect.begin() + pos);
 		}
@@ -256,8 +254,8 @@
 		List<T> reverse() const
 		{	List<T> rev;
 
-			for (const T& val : c_rev<T> (*this))
-				rev << val;
+			for (auto it = end() - 1; it != begin(); --it)
+				rev << *it;
 
 			return rev;
 		}
@@ -266,7 +264,7 @@
 		{	m_vect.clear();
 		}
 
-		void insert (ulong pos, const T& value)
+		void insert (int pos, const T& value)
 		{	m_vect.insert (m_vect.begin() + pos, value);
 		}
 
@@ -278,16 +276,16 @@
 			resize (std::distance (begin(), pos));
 		}
 
-		ulong size() const
+		int size() const
 		{	return m_vect.size();
 		}
 
-		T& operator[] (ulong n)
+		T& operator[] (int n)
 		{	assert (n < size());
 			return m_vect[n];
 		}
 
-		const T& operator[] (ulong n) const
+		const T& operator[] (int n) const
 		{	assert (n < size());
 			return m_vect[n];
 		}
@@ -300,17 +298,17 @@
 		{	std::sort (begin(), end());
 		}
 
-		ulong find (const T& needle)
-		{	ulong i = 0;
+		int find (const T& needle)
+		{	int i = 0;
 
-		for (const T & hay : *this)
+			for (const T & hay : *this)
 			{	if (hay == needle)
 					return i;
 
 				i++;
 			}
 
-			return -1u;
+			return -1;
 		}
 
 	private:
@@ -320,63 +318,6 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-// ListReverser (aka rev)
-//
-// Helper class used to reverse-iterate Lists in range-for-loops.
-// =============================================================================
-template<class T> class ListReverser
-{	public:
-		typedef typename List<T>::ReverseIterator Iterator;
-
-		ListReverser (List<T>& vect)
-		{	m_vect = &vect;
-		}
-
-		Iterator begin()
-		{	return m_vect->rbegin();
-		}
-
-		Iterator end()
-		{	return m_vect->rend();
-		}
-
-	private:
-		List<T>* m_vect;
-};
-
-// =============================================================================
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-// =============================================================================
-// ConstListReverser (aka c_rev)
-//
-// Like ListReverser, except works on const Lists.
-// =============================================================================
-template<class T> class ConstListReverser
-{	public:
-		typedef typename List<T>::ConstReverseIterator Iterator;
-
-		ConstListReverser (const List<T>& vect)
-		{	m_vect = &vect;
-		}
-
-		Iterator begin() const
-		{	return m_vect->crbegin();
-		}
-
-		Iterator end() const
-		{	return m_vect->crend();
-		}
-
-	private:
-		const List<T>* m_vect;
-};
-
-template<class T> using rev = ListReverser<T>;
-template<class T> using c_rev = ConstListReverser<T>;
-
-// =============================================================================
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-// =============================================================================
 // StringFormatArg
 //
 // Converts a given value into a string that can be retrieved with ::value().
@@ -416,9 +357,9 @@
 		template<class T> StringFormatArg (const List<T>& v)
 		{	m_val = "{ ";
 
-			uint i = 0;
+			int i = 0;
 
-		for (const T & it : v)
+			for (const T& it : v)
 			{	if (i++)
 					m_val += ", ";
 
--- a/src/widgets.cpp	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/widgets.cpp	Sat Oct 05 15:18:47 2013 +0300
@@ -124,7 +124,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void RadioGroup::setCurrentRow (uint row)
+void RadioGroup::setCurrentRow (int row)
 {	m_currentLayout = m_layouts[row];
 }
 
@@ -142,7 +142,7 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-QRadioButton* RadioGroup::operator[] (uint n) const
+QRadioButton* RadioGroup::operator[] (int n) const
 {	return m_objects[n];
 }
 
--- a/src/widgets.h	Sat Oct 05 12:51:13 2013 +0300
+++ b/src/widgets.h	Sat Oct 05 15:18:47 2013 +0300
@@ -61,11 +61,11 @@
 		void            init (Qt::Orientation orient);
 		bool            isChecked (int n) const;
 		void            rowBreak();
-		void            setCurrentRow (uint row);
+		void            setCurrentRow (int row);
 		void            setValue (int val);
 		int             value() const;
 
-		QRadioButton*   operator[] (uint n) const;
+		QRadioButton*   operator[] (int n) const;
 		RadioGroup&     operator<< (QRadioButton* button);
 		RadioGroup&     operator<< (const char* entry);
 

mercurial