  };
  
  extern DLL_EXPORT CLogger tlog0; //green - standard progress info
+Index: client/GUIBase.cpp
+===================================================================
+--- client/GUIBase.cpp	(revision 2170)
++++ client/GUIBase.cpp	(working copy)
+@@ -11,6 +11,7 @@
+ #include "../CThreadHelper.h"
+ #include "CConfigHandler.h"
+ #include <boost/lexical_cast.hpp>
++
+ 
+ /*
+  * GUIBase.cpp, part of VCMI engine
+@@ -364,6 +365,26 @@
+ 		}
+ 	} HANDLE_EXCEPTION
+ }
++
++void CGuiHandler::loopInitFromMainThread()
++{
++	setThreadName(-1, "CGuiHandler::run");
++	CCS->curh->centerCursor();
++	mainFPSmng->init(); // resets internal clock, needed for FPS manager
++}
++
++bool CGuiHandler::loopFromMainThread()
++{
++	if(terminate)
++		return false;
++	if(curInt)
++		curInt->update(); // calls a update and drawing process of the loaded game interface object at the moment
++			
++	mainFPSmng->framerateDelay(); // holds a constant FPS
++	return true;
++}
++
++
+ 
+ CGuiHandler::CGuiHandler()
+ :lastClick(-500, -500)
 Index: client/CMT.cpp
 ===================================================================
 --- client/CMT.cpp	(revision 2170)
 +++ client/CMT.cpp	(working copy)
-@@ -55,6 +55,8 @@
- #if __MINGW32__
- #undef main
- #endif
-+
-+
- 
- namespace po = boost::program_options;
- 
-@@ -92,6 +94,7 @@
+@@ -90,8 +92,10 @@
+ void dispose();
+ void playIntro();
  static void listenForEvents();
++static bool loopListenForEvents(bool block);
  void requestChangingResolution();
  void startGame(StartInfo * options, CConnection *serv = NULL);
 +
  
  #ifndef _WIN32
  #ifndef _GNU_SOURCE
-@@ -102,6 +105,7 @@
- 
- void init()
- {
-+	__android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
- 	timeHandler tmh, pomtime;
- #if SDL_BYTEORDER == SDL_BIG_ENDIAN
- 	int rmask = 0xff000000;int gmask = 0x00ff0000;int bmask = 0x0000ff00;int amask = 0x000000ff;
-@@ -157,8 +161,11 @@
- 	tlog0<<"\tMain graphics: "<<tmh.getDif()<<std::endl;
- 	tlog0<<"Initializing game graphics: "<<tmh.getDif()<<std::endl;
- 
-+	__android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
- 	CMessage::init();
-+	__android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
- 	tlog0<<"Message handler: "<<tmh.getDif()<<std::endl;
-+	__android_log_print(ANDROID_LOG_DEBUG, "VCMI", "Check at %s in %s:%i", __FUNCTION__, __FILE__, __LINE__);
- 	//CPG = new CPreGame(); //main menu and submenus
- 	//tlog0<<"Initialization CPreGame (together): "<<tmh.getDif()<<std::endl;
- }
-@@ -184,19 +191,26 @@
+@@ -126,6 +130,7 @@
+ 			GDefaultOptions.settingsChanged();
+ 		}
+ 	}
++
+ 	THC tlog0<<"\tLoading default system settings: "<<pomtime.getDif()<<std::endl;
+ 
+ 	//initializing audio
+@@ -135,10 +140,12 @@
+ 	CCS->soundh->init();
+ 	CCS->soundh->setVolume(GDefaultOptions.soundVolume);
+ 	CCS->musich = new CMusicHandler;
++
+ 	//CGI->musich->init();
+ 	//CGI->musich->setVolume(GDefaultOptions.musicVolume);
+ 	tlog0<<"\tInitializing sound: "<<pomtime.getDif()<<std::endl;
+ 	tlog0<<"Initializing screen and sound handling: "<<tmh.getDif()<<std::endl;
++
+ 
+ 	initDLL(::console,logfile);
+ 	const_cast<CGameInfo*>(CGI)->setFromLib();
+@@ -184,11 +191,15 @@
  }
  
  

===================================================================
--- server/CGameHandler.cpp	(revision 2170)
+++ server/CGameHandler.cpp	(working copy)
@@ -24,6 +24,7 @@
 #include <boost/random/variate_generator.hpp>
 #include <boost/random/poisson_distribution.hpp>
 #include "../lib/CCreatureSet.h"
+
 
 /*
  * CGameHandler.cpp, part of VCMI engine
@@ -1786,7 +1787,7 @@
 		iw.player = h1->tempOwner;
 		iw.components.push_back(Component(Component::SEC_SKILL, 18, ScholarLevel, 0));

 #endif
+#endif
 {
 	tlog0 << "Starting... " << std::endl;      
 	po::options_description opts("Allowed options");
@@ -235,7 +246,6 @@
 	console->start();
 	atexit(dispose);
 	tlog0 <<"Creating console and logfile: "<<pomtime.getDif() << std::endl;
-
 	conf.init();
 	tlog0 <<"Loading settings: "<<pomtime.getDif() << std::endl;
 	tlog0 << NAME << std::endl;
@@ -260,14 +270,18 @@
 	tlog0<<"\tInitializing video: "<<pomtime.getDif()<<std::endl;
 
 	//we can properly play intro only in the main thread, so we have to move loading to the separate thread
-	boost::thread loading(init);
-
+#ifdef ANDROID
+	init();
 	if(!vm.count("battle") && !vm.count("nointro"))
 		playIntro();
+#else
+	boost::thread loading(init);
 
+
 	SDL_FillRect(screen,NULL,0);
 	CSDL_Ext::update(screen);
 	loading.join();
+#endif
 	tlog0<<"Initialization of VCMI (together): "<<total.getDif()<<std::endl;
 
 	if(!vm.count("battle"))
@@ -284,8 +298,16 @@
 		si->playerInfos[1].color = 1;
 		startGame(si);
 	}
+#ifdef ANDROID
+	GH.loopInitFromMainThread();
+	while( GH.loopFromMainThread() )
+	{
+		while( loopListenForEvents(false) );
+	}
+#else
 	mainGUIThread = new boost::thread(&CGuiHandler::run, boost::ref(GH));
 	listenForEvents();
+#endif
 
 	return 0;
 }
@@ -535,10 +557,12 @@
 		tlog2 << "Warning: SDL says that "  << bpp << "bpp is wrong and suggests " << suggestedBpp << std::endl;
 	}
 
