Reverted changes on LDSubfile::getContents, I had a temporary, hackier solution there and forgot to change it back

Sun, 24 Mar 2013 21:45:19 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sun, 24 Mar 2013 21:45:19 +0200
changeset 65
e4f25b44e240
parent 64
ada4679d5bce
child 66
12aca5d5a51e

Reverted changes on LDSubfile::getContents, I had a temporary, hackier solution there and forgot to change it back

file.cpp file | annotate | diff | comparison | revisions
ldtypes.cpp file | annotate | diff | comparison | revisions
--- a/file.cpp	Sun Mar 24 21:41:24 2013 +0200
+++ b/file.cpp	Sun Mar 24 21:45:19 2013 +0200
@@ -113,8 +113,8 @@
 // =============================================================================
 // Clear everything from the model
 void OpenFile::close () {
-	for (ulong j = 0; j < objects.size(); ++j)
-		delete objects[j];
+	FOREACH (LDObject, *, obj, objects)
+		delete obj;
 	
 	delete this;
 }
@@ -127,10 +127,8 @@
 		return;
 	
 	// Remove all loaded files and the objects they contain
-	for (ushort i = 0; i < g_LoadedFiles.size(); i++) {
-		OpenFile* f = g_LoadedFiles[i];
+	FOREACH (OpenFile, *, f, g_LoadedFiles)
 		f->close ();
-	}
 	
 	// Clear the array
 	g_LoadedFiles.clear();
@@ -187,9 +185,7 @@
 		return false;
 	
 	// Write all entries now
-	for (ulong i = 0; i < objects.size(); ++i) {
-		LDObject* obj = objects[i];
-		
+	FOREACH (LDObject, *, obj, objects) {
 		// LDraw requires lines to have DOS line endings
 		str zLine = str::mkfmt ("%s\r\n",obj->getContents ().chars ());
 		
--- a/ldtypes.cpp	Sun Mar 24 21:41:24 2013 +0200
+++ b/ldtypes.cpp	Sun Mar 24 21:45:19 2013 +0200
@@ -127,13 +127,14 @@
 	return str::mkfmt ("0 %s", zText.chars ());
 }
 
-#define MATVAL(N) ftoa (mMatrix[N]).chars()
 str LDSubfile::getContents () {
-	return str::mkfmt ("1 %d %s %s %s %s %s %s %s %s %s %s %s",
-		dColor, vPosition.getStringRep (false).chars (),
-		MATVAL (0), MATVAL (1), MATVAL (2),
-		MATVAL (4), MATVAL (5), MATVAL (6),
-		MATVAL (8), MATVAL (9), MATVAL (10), zFileName.chars());
+	str val = str::mkfmt ("1 %d %s ", dColor, vPosition.getStringRep (false).chars ());
+	
+	for (short i = 0; i < 9; ++i)
+		val.appendformat ("%s ", ftoa (mMatrix[i]).chars());
+	
+	val += zFileName;
+	return val;
 }
 
 str LDLine::getContents () {

mercurial