Fix crash if Ctrl is held down while loading a mod. miscellaneous-fixes
authorachurch
Sun, 03 Apr 2011 02:46:27 +0900
branchmiscellaneous-fixes
changeset 662 48ca2d926ca9
parent 661 2653b576a562
child 663 a4103c11bc5b
Fix crash if Ctrl is held down while loading a mod. This patch fixes an oversight in the scene editor initialization code which can cause a crash if the Ctrl key is held down when a mod is loaded.
Aquaria/Game.h
Aquaria/SceneEditor.cpp
--- a/Aquaria/Game.h	Sun Apr 03 02:02:53 2011 +0900
+++ b/Aquaria/Game.h	Sun Apr 03 02:46:27 2011 +0900
@@ -407,6 +407,7 @@
 	void update(float dt);
 	void prevElement();
 	void nextElement();
+	void doPrevElement();
 	Element *cycleElementNext(Element *e);
 	Element *cycleElementPrev(Element *e);
 	void selectZero();
--- a/Aquaria/SceneEditor.cpp	Sun Apr 03 02:02:53 2011 +0900
+++ b/Aquaria/SceneEditor.cpp	Sun Apr 03 02:46:27 2011 +0900
@@ -775,7 +775,7 @@
 
 	updateText();
 
-	prevElement();
+	doPrevElement();
 }
 
 void SceneEditor::alignHorz()
@@ -2980,24 +2980,29 @@
 		}
 		else 
 		{
-			int oldCur = curElement;
-			curElement--;
-			if (curElement < 0)
-				curElement = dsq->game->elementTemplates.size()-1;
-
-			if (dsq->game->elementTemplates[curElement].idx < 1024)
-			{
-				//int idx = dsq->game->elementTemplates[curElement].idx;
-				placer->setTexture(dsq->game->elementTemplates[curElement].gfx);
-			}
-			else
-			{
-				curElement = oldCur;
-			}
+			doPrevElement();
 		}
 	}
 }
 
+void SceneEditor::doPrevElement()
+{
+	int oldCur = curElement;
+	curElement--;
+	if (curElement < 0)
+		curElement = dsq->game->elementTemplates.size()-1;
+
+	if (dsq->game->elementTemplates[curElement].idx < 1024)
+	{
+		//int idx = dsq->game->elementTemplates[curElement].idx;
+		placer->setTexture(dsq->game->elementTemplates[curElement].gfx);
+	}
+	else
+	{
+		curElement = oldCur;
+	}
+}
+
 void SceneEditor::moveLayer()
 {
 	std::string s = dsq->getUserInputString("Enter 'fromLayer toLayer' (space inbetween, ESC/m-ty to cancel)");