src/video/allegro_v.cpp
changeset 10380 f4adb9648a93
parent 10379 dd9d0aade65e
child 10381 c043aa0c1695
--- a/src/video/allegro_v.cpp	Tue Nov 25 19:32:12 2008 +0000
+++ b/src/video/allegro_v.cpp	Tue Nov 25 21:09:00 2008 +0000
@@ -374,9 +374,14 @@
 	}
 }
 
+/** There are multiple modules that might be using Allegro and
+ * Allegro can only be initiated once. */
+int _allegro_count = 0;
+
 const char *VideoDriver_Allegro::Start(const char * const *parm)
 {
-	if (install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return NULL;
+	if (_allegro_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return NULL;
+	_allegro_count++;
 
 	install_timer();
 	install_mouse();
@@ -391,7 +396,7 @@
 
 void VideoDriver_Allegro::Stop()
 {
-	allegro_exit();
+	if (--_allegro_count == 0) allegro_exit();
 }
 
 #if defined(UNIX) || defined(__OS2__) || defined(PSP)
@@ -431,7 +436,7 @@
 #else
 		/* Speedup when pressing tab, except when using ALT+TAB
 		 * to switch to another application */
-		if (keys[KEY_TAB] && (key_shifts & KB_ALT_FLAG) == 0)
+		if (key[KEY_TAB] && (key_shifts & KB_ALT_FLAG) == 0)
 #endif
 		{
 			if (!_networking && _game_mode != GM_MENU) _fast_forward |= 2;