瀏覽代碼

Fixed #504. More logging for #419.

Michał W. Urbańczyk 15 年之前
父節點
當前提交
9febb357ff
共有 2 個文件被更改,包括 30 次插入13 次删除
  1. 23 12
      client/CMT.cpp
  2. 7 1
      hch/CObjectHandler.cpp

+ 23 - 12
client/CMT.cpp

@@ -86,6 +86,7 @@ static void setScreenRes(int w, int h, int bpp, bool fullscreen);
 void dispose();
 void playIntro();
 static void listenForEvents();
+void requestChangingResolution();
 
 #ifndef _WIN32
 #ifndef _GNU_SOURCE
@@ -531,6 +532,7 @@ static void setScreenRes(int w, int h, int bpp, bool fullscreen)
 	//TODO: centering game window on other platforms (or does the environment do their job correctly there?)
 
 	screenBuf = bufOnScreen ? screen : screen2;
+	setResolution = true;
 }
 
 static void listenForEvents()
@@ -572,8 +574,8 @@ static void listenForEvents()
 		}
 		else if(ev->type == SDL_USEREVENT && ev->user.code == 1)
 		{
+			tlog0 << "Changing resolution has been requested\n";
 			setScreenRes(conf.cc.resx,conf.cc.resy,conf.cc.bpp,conf.cc.fullscreen);
-			setResolution = true;
 			delete ev;
 			continue;
 		}
@@ -611,15 +613,18 @@ void startGame(StartInfo * options)
 
 	if(screen->w != conf.cc.resx   ||   screen->h != conf.cc.resy)
 	{
-		//push special event to order event reading thread to change resolution
-		SDL_Event ev;
-		ev.type = SDL_USEREVENT;
-		ev.user.code = 1;
-		SDL_PushEvent(&ev);
+		requestChangingResolution();
+
+		//allow event handling thread change resolution
+		eventsM.unlock();
+		while(!setResolution) boost::this_thread::sleep(boost::posix_time::milliseconds(50));
+		eventsM.lock();
 	}
 	else
 		setResolution = true;
 
+
+
 	client = new CClient;
 	switch(options->mode) //new game
 	{
@@ -635,11 +640,17 @@ void startGame(StartInfo * options)
 	}
 
 	CGI->musich->stopMusic();
-
-	//allow event handling thread change resolution
-	eventsM.unlock();
-	while(!setResolution) boost::this_thread::sleep(boost::posix_time::milliseconds(50));
-	eventsM.lock();
-
 	client->connectionHandler = new boost::thread(&CClient::run, client);
 }
+
+void requestChangingResolution()
+{
+	//mark that we are going to change resolution
+	setResolution = false;
+
+	//push special event to order event reading thread to change resolution
+	SDL_Event ev;
+	ev.type = SDL_USEREVENT;
+	ev.user.code = 1;
+	SDL_PushEvent(&ev);
+}

+ 7 - 1
hch/CObjectHandler.cpp

@@ -6206,7 +6206,13 @@ void CGObelisk::setPropertyDer( ui8 what, ui32 val )
 	case 20:
 		assert(val < PLAYER_LIMIT);
 		visited[val]++;
-		assert(visited[val] <= obeliskCount);
+
+		if(visited[val] > obeliskCount)
+		{
+			tlog0 << "Error: Visited " << visited[val] << "\t\t" << obeliskCount << std::endl;
+			assert(0);
+		}
+
 		break;
 	}
 }